package com.niit.spark.sql.test

import org.apache.spark.sql.{DataFrame, SparkSession}

/**
 * Date:2025/5/16
 * Author：Ys
 * Description:
 */
object CSVToDataFrame {

  def main(args: Array[String]): Unit = {
    //环境准备
    val spark = SparkSession.builder().appName("CSVToDataFrame").master("local[*]").getOrCreate()
    spark.sparkContext.setLogLevel("ERROR")
    import spark.implicits._

    //读取CSV文件转换成 DataFrame
    val df: DataFrame = spark.read.option("header", "true").csv("input/sql/sales.csv")

    df.show()
    //关闭环境 stop和close任选其一
    spark.stop()


  }

}
